package com.yyw.rabbitmq.core.core;

import com.yyw.rabbitmq.api.Message;
import com.yyw.rabbitmq.api.MessageCallBack;
import com.yyw.rabbitmq.api.MessageProduct;
import com.yyw.rabbitmq.api.MessageType;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 消费者客户端
 */
public class ProductClient implements MessageProduct {

    @Autowired
    private RabbitBroker rabbitBroker;

    @Override
    public void send(Message message) {
        String messageType = message.getMessageType();
        switch (messageType) {
            case MessageType.QUICK:
                // 发送快速消息
                rabbitBroker.sendQuick(message);
                break;
            case MessageType.CONFIRM:
                // 发送确认消息
                rabbitBroker.sendConfirm(message);
                break;
            case MessageType.RELIABLE:
                // 发送可靠性消息
                rabbitBroker.sendReliable(message);
                break;
            default:
                break;
        }
    }

    @Override
    public void send(Message message, MessageCallBack callBack) {

    }

    @Override
    public void send(List<Message> messages) {

    }
}
